<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<title>TOZERO 问答 登入</title>

		<meta name="description" content="User login page" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />

		<!-- basic styles -->

		<link href="/gz31/wenda/Public/assets/css/bootstrap.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="/gz31/wenda/Public/assets/css/font-awesome.min.css" />

		<!--[if IE 7]>
		  <link rel="stylesheet" href="/gz31/wenda/Public/assets/css/font-awesome-ie7.min.css" />
		<![endif]-->

		<!-- page specific plugin styles -->

		<!-- fonts -->

		<link rel="stylesheet" href="/gz31/wenda/Public/assets/css/ace-fonts.css" />

		<!-- ace styles -->

		<link rel="stylesheet" href="/gz31/wenda/Public/assets/css/ace.min.css" />
		<link rel="stylesheet" href="/gz31/wenda/Public/assets/css/ace-rtl.min.css" />

		<!--[if lte IE 8]>
		  <link rel="stylesheet" href="/gz31/wenda/Public/assets/css/ace-ie.min.css" />
		<![endif]-->

		<!-- inline styles related to this page -->

		<!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->

		<!--[if lt IE 9]>
		<script src="/gz31/wenda/Public/assets/js/html5shiv.js"></script>
		<script src="/gz31/wenda/Public/assets/js/respond.min.js"></script>
		<![endif]-->
	</head>

	<body class="login-layout">
		<div class="main-container">
			<div class="main-content">
				<div class="row">
					<div class="col-sm-10 col-sm-offset-1">
						<div class="login-container">
							<div class="center">
								<h1>
									<i class="icon-leaf green"></i>
									<span class="red">从零开始</span>
									<span class="white">To Zero</span>
								</h1>
								<h4 class="blue">&copy; 广州训练营</h4>
							</div>

							<div class="space-6"></div>
						<!-- 登入 -->
							<div class="position-relative">
								<div id="login-box" class="login-box visible widget-box no-border">
									<div class="widget-body">
										<div class="widget-main">
											<h4 class="header blue lighter bigger">
												<i class="icon-coffee green"></i>
												请输入账号密码
											</h4>

											<div class="space-6"></div>

											<form>
												<fieldset>
													<label class="block clearfix">
														<span class="block input-icon input-icon-right">
															<input type="text" class="form-control" placeholder="admin01" name="username" />
															<i class="icon-user"></i>
														</span>
													</label>

													<label class="block clearfix">
														<span class="block input-icon input-icon-right">
															<input type="password" class="form-control" placeholder="123456" name="password" />
															<i class="icon-lock"></i>
														</span>
													</label>
													
													<label class="block clearfix">
														<span class="block input-icon input-icon-right">
															<div id="embed-captcha"></div>
    								<p id="wait" class="show"><i class="icon-spinner icon-spin orange bigger-125"></i>正在加载验证码......</p>
    									<p id="notice" class="hide  text-warning bigger-110 orange"><i class="icon-warning-sign"></i>请先完成验证</p>
														</span>
													</label>

													<div class="space"></div>

													<div class="clearfix">
														<label class="inline">
															<input type="checkbox" class="ace" />
															<span class="lbl"> 7天免登入</span>
														</label>

														<button id="embed-submit" type="button" class="width-35 pull-right btn btn-sm btn-primary">
															<i class="icon-key"></i>
															登入
														</button>
													</div>

													<div class="space-4"></div>
												</fieldset>
											</form>

											<div class="social-or-login center">
												<span class="bigger-110">第三方登入</span>
											</div>

											<div class="social-login center">
												<a class="btn btn-primary">
													<i class="icon-facebook"></i>
												</a>

												<a class="btn btn-info">
													<i class="icon-twitter"></i>
												</a>

												<a class="btn btn-danger">
													<i class="icon-google-plus"></i>
												</a>
											</div>
										</div><!-- /widget-main -->

										<div class="toolbar clearfix">
											<div>
												<a href="#" onclick="show_box('forgot-box'); return false;" class="forgot-password-link">
													<i class="icon-arrow-left"></i>
													忘记密码
												</a>
											</div>

											<div>
												<a href="#" onclick="show_box('signup-box'); return false;" class="user-signup-link">
													注册
													<i class="icon-arrow-right"></i>
												</a>
											</div>
										</div>
									</div><!-- /widget-body -->
								</div><!-- /login-box -->

								<div id="forgot-box" class="forgot-box widget-box no-border">
									<div class="widget-body">
										<div class="widget-main">
											<h4 class="header red lighter bigger">
												<i class="icon-key"></i>
												重置密码
											</h4>

											<div class="space-6"></div>
											<p>
												Enter your email and to receive instructions
											</p>

											<form>
												<fieldset>
													<label class="block clearfix">
														<span class="block input-icon input-icon-right">
															<input type="email" class="form-control" placeholder="Email" />
															<i class="icon-envelope"></i>
														</span>
													</label>

													<div class="clearfix">
														<button type="button" class="width-35 pull-right btn btn-sm btn-danger">
															<i class="icon-lightbulb"></i>
															Send Me!
														</button>
													</div>
												</fieldset>
											</form>
										</div><!-- /widget-main -->

										<div class="toolbar center">
											<a href="#" onclick="show_box('login-box'); return false;" class="back-to-login-link">
												返回登入
												<i class="icon-arrow-right"></i>
											</a>
										</div>
									</div><!-- /widget-body -->
								</div><!-- /forgot-box -->
							<!-- 注册 -->
								<div id="signup-box" class="signup-box widget-box no-border">
									<div class="widget-body">
										<div class="widget-main">
											<h4 class="header green lighter bigger">
												<i class="icon-group blue"></i>
												注册新用户
											</h4>

											<div class="space-6"></div>
											<p> Enter your details to begin: </p>

											<form>
												<fieldset>
													<label class="block clearfix">
														<span class="block input-icon input-icon-right">
															<input type="email" class="form-control" placeholder="用户名" name="username" min="6" />
															<i class="icon-user"></i>
														</span>
													</label>

													<label class="block clearfix">
														<span class="block input-icon input-icon-right">
															<input type="password" class="form-control" placeholder="密码" />
															<i class="icon-lock"></i>
														</span>
													</label>

													<label class="block clearfix">
														<span class="block input-icon input-icon-right">
															<input type="password" class="form-control" placeholder="重复确认密码" />
															<i class="icon-retweet"></i>
														</span>
													</label>
													<label class="block clearfix">
														<span class="block input-icon input-icon-right">
															<input type="password" class="form-control" placeholder="手机号码" />
															<i class="icon-phone"></i>
														</span>
													</label>
													<label class="block clearfix">
														<span class="block input-icon input-icon-right">
															<input type="password" class="form-control" placeholder="输入手机验证短信" />
															<i class="icon-retweet"></i>
															<button class="btn btn-small success" type="button">获取验证码</button>
														</span>
														<span class="block input-icon">
														</span>
													</label>
													<label class="block">
														<input type="checkbox" class="ace" />
														<span class="lbl">
															同意
															<a href="#">用户守则</a>
														</span>
													</label>

													<div class="space-24"></div>

													<div class="clearfix">
														<button type="reset" class="width-30 pull-left btn btn-sm">
															<i class="icon-refresh"></i>
															重置
														</button>

														<button type="button" class="width-65 pull-right btn btn-sm btn-success">
															注册
															<i class="icon-arrow-right icon-on-right"></i>
														</button>
													</div>
												</fieldset>
											</form>
										</div>

										<div class="toolbar center">
											<a href="#" onclick="show_box('login-box'); return false;" class="back-to-login-link">
												<i class="icon-arrow-left"></i>
												已有账号，返回登入
											</a>
										</div>
									</div><!-- /widget-body -->
								</div><!-- /signup-box -->
							</div><!-- /position-relative -->
						</div>
					</div><!-- /.col -->
				</div><!-- /.row -->
			</div>
		</div><!-- /.main-container -->

		<!-- basic scripts -->

		<!--[if !IE]> -->

		<script type="text/javascript">
			window.jQuery || document.write("<script src='/gz31/wenda/Public/assets/js/jquery-2.0.3.min.js'>"+"<"+"/script>");
		</script>

		<!-- <![endif]-->

		<!--[if IE]>
<script type="text/javascript">
 window.jQuery || document.write("<script src='/gz31/wenda/Public/assets/js/jquery-1.10.2.min.js'>"+"<"+"/script>");
</script>
<![endif]-->

		<script type="text/javascript">
			if("ontouchend" in document) document.write("<script src='/gz31/wenda/Public/assets/js/jquery.mobile.custom.min.js'>"+"<"+"/script>");
		</script>

		<!-- 该页所有的javascript代码 -->
		<script src='/gz31/wenda/Public/common/gt.js'></script>
		<script src='/gz31/wenda/Public/dialog/layer/layer.js'></script>
		<script src='/gz31/wenda/Public/dialog/dialog.js'></script>
		<script src='/gz31/wenda/Public/common/common.js'></script>
		<script type="text/javascript">
			function show_box(id) {
			 jQuery('.widget-box.visible').removeClass('visible');
			 jQuery('#'+id).addClass('visible');
			}



		    var handlerEmbed = function (captchaObj) {
		    	console.log(captchaObj)
		        $("#embed-submit").click(function (e) {
		        	var username = $("form").first().serializeArray()[0].value;
					var password = $("form").first().serializeArray()[1].value;
					if (!username && !password) {
						return dialog.error("用户名和密码不能为空");
					}
		        	// 判断是否进行了本地的图片验证
		            var validate = captchaObj.getValidate();
		            if (!validate) {
		                $("#notice")[0].className = "show";
		                setTimeout(function () {
		                    $("#notice")[0].className = "hide";
		                }, 2000);
		                e.preventDefault();
		                return;
		            }
		            // 进行ajax提交
		            check_verify(username, password);
		        });
		        // 将验证码加到id为captcha的元素里，同时会有三个input的值：geetest_challenge, geetest_validate, geetest_seccode
		        captchaObj.appendTo("#embed-captcha");
		        captchaObj.onReady(function () {
		            $("#wait")[0].className = "hide";
		        });
		        // 更多接口参考：http://www.geetest.com/install/sections/idx-client-sdk.html
		    };
	    	var url = "<?php echo U('login/get_geetest');?>";
		    $.ajax({
		        // 获取id，challenge，success（是否启用failback）
		        url: url+"?t=" + (new Date()).getTime(), // 加随机数防止缓存
		        type: "get",
		        dataType: "json",
		        success: function (data) {
		            console.log(data);
		            // 使用initGeetest接口
		            // 参数1：配置参数
		            // 参数2：回调，回调的第一个参数验证码对象，之后可以使用它做appendTo之类的事件
		            initGeetest({
		                gt: data.gt,
		                challenge: data.challenge,
		                new_captcha: data.new_captcha,
		                // product: "embed", // 产品形式，包括：float，embed，popup。注意只对PC版验证码有效
		                // product: "float", 
		                product: "popup", 
		                offline: !data.success // 表示用户后台检测极验服务器是否宕机，一般不需要关注
		                // 更多配置参数请参见：http://www.geetest.com/install/sections/idx-client-sdk.html#config
		            }, handlerEmbed);
		        }
		    });

		    /*判断验证是否成功*/
		    function check_verify(username, password)
			{ 

				// 组合验证需要用的数据
		        var postData={
		            geetest_challenge: $('.geetest_challenge').val(),
		            geetest_validate: $('.geetest_validate').val(),
		            geetest_seccode: $('.geetest_seccode').val(),
		            username: username,
		            password: password
		        }
		        // 验证是否通过
		        $.post("<?php echo U('Home/Login/geetest_ajax_check');?>", postData, function(res) {
		        	console.log(res)
		            if (res == 1) {
		                dialog.success('登入成功', "<?php echo U('Index/index');?>");
		            } else if(res == 2){
		            	dialog.error('账号或密码错误');
		            }
		            else{
		                dialog.showMessage('网络错误，稍等...', 5);
		            }
		        });
			}

		</script>
	</body>
</html>